package com.sky.controller.admin;

import com.sky.dto.ReportDto;
import com.sky.result.Result;
import com.sky.service.ReportService;
import com.sky.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = "数据统计接口")
@RequestMapping("/admin/report")
@Slf4j
public class ReportController {
    @Autowired
    private ReportService reportService;

    /**
     * 订单统计
     * @param dto
     * @return
     */
    @ApiOperation("订单统计")
    @GetMapping("/ordersStatistics")
    public Result ordersStatistics(ReportDto dto){
        OrderReportVO vo = reportService.ordersStatistics(dto);
        return Result.success(vo);
    }

    /**
     * 营业额统计
     * @param dto
     * @return
     */
    @ApiOperation("营业额统计")
    @GetMapping("/turnoverStatistics")
    public Result turnoverStatistics(ReportDto dto){
        TurnoverReportVO vo = reportService.turnoverStatistics(dto);
        return Result.success(vo);
    }

    /**
     * 用户统计接口
     * @param dto
     * @return
     */
    @ApiOperation("用户统计接口")
    @GetMapping("/userStatistics")
    public Result userStatistics(ReportDto dto){
        UserReportVO vo = reportService.userStatistics(dto);
        return Result.success(vo);
    }

    /**
     * 查询销量排名top10
     * @param dto
     * @return
     */
    @ApiOperation("查询销量排名top10")
    @GetMapping("/top10")
    public Result top10(ReportDto dto){
        SalesTop10ReportVO vo = reportService.top10(dto);
        return Result.success(vo);
    }
}
